package org.lql.algo.codecrush.week007;

/**
 * @author: liangqinglong
 * @date: 2025-08-18 13:35
 * @description: 153. 寻找旋转排序数组中的最小值 <a href="https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/description/">...</a>
 **/
public class FindMin {

	public int findMin(int[] nums) {
		int left = 0;
		int right = nums.length - 1;
		while (left < right) {
			int mid = (left + right) / 2;
			if (nums[mid] > nums[right]) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return nums[right];
	}

	public static void main(String[] args) {
		int[] nums = {3, 4, 5, 1, 2};
		FindMin findMin = new FindMin();
		System.out.println(findMin.findMin(nums));
	}
}
